package com.example.designpatten.chapter2_strategypatten.strategy;

//现金收取工厂
//简单工厂 + 策略模式
public class CashContext {
    //现金处理方案
    private CashSuper cs;

    public CashContext(String type) {
        switch (type) {
            //正常收费
            case "1":
                cs = new CashNormal();
                break;
                //打8折
            case "2":
                cs = new CashRebate("0.8");
                break;
                //满300返100
            case "3":
                cs = new CashReturn("300", "100");
                break;
            default:
                throw new RuntimeException("没有当前打折方案！");
        }
    }

    public double getResult(double money) {
        return cs.acceptCash(money);
    }
}
